package com.zhj.business.protocol.input;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhj.business.protocol.validhandler.BirthdayValidHandler;
import com.zhj.common.web.valid.annotation.MyValid;
import lombok.Data;

import javax.validation.constraints.*;
import java.util.Date;

/**
 * @author zhj
 */
@Data
@MyValid(message = "年龄和生日不匹配", handler = BirthdayValidHandler.class)
public class StudentInput {

    @NotNull(message = "名字不能为空")
    private String name;
    @Min(value = 1, message = "年龄不能小于1")
    @Max(value = 25, message = "年龄不能超过25")
    private Integer age;
    @NotNull(message = "邮箱不能为空")
    @Email(message = "必须是邮箱格式")
    private String email;
    @NotNull(message = "性别不能为空")
    private Integer sex;
    @NotNull(message = "生日不能为空")
    @Past(message = "生日范围不正确，生日必须是今天以前的")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date birthday;
}

